package main

import (
	// "fmt"
	"html/template"
	"log"
	"net/http"
)

type User struct {
	Name  string
	Count int
}

var num int = 0

func HelloServer(w http.ResponseWriter, req *http.Request) {

	num++

	requestParam := req.URL.Path[1:]
	// fmt.Printf("Hello, %s,%d\n", requestParam, num)
	t, err := template.ParseFiles("../static/index.html")
	if err != nil {
		log.Println(err)
	}

	t.Execute(w, &User{requestParam, num})

}

func main() {
	//设置路由
	http.Handle("/css/", http.FileServer(http.Dir("../static/")))
	http.Handle("/js/", http.FileServer(http.Dir("../static/")))
	http.Handle("/images/", http.FileServer(http.Dir("../static/")))
	http.HandleFunc("/hello", HelloServer)
	http.ListenAndServe(":8888", nil)
}
